package ro.ase.catalog.security.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import ro.ase.catalog.beans.SchoolClass;
import ro.ase.catalog.beans.Teacher;
import ro.ase.catalog.beans.User;
import ro.ase.catalog.beans.dto.TeacherDTO;
import ro.ase.catalog.security.dao.ITeacherDAO;
import ro.ase.catalog.security.service.ITeacherService;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Ioana
 * Date: 5/12/14
 * Time: 9:40 PM
 * To change this template use File | Settings | File Templates.
 */
public class TeacherServiceImpl implements ITeacherService {
    @Autowired
    private ITeacherDAO teacherDAO;
    public void addTeacher(Teacher teacher) {
        teacherDAO.save(teacher)  ;
    }

    public Boolean saveTransactionalTeacher(User user, Teacher teacher) {
        return teacherDAO.saveTransactionalTeacher(user, teacher) ;
    }

    public Teacher getByLastNameFirstName(String lastName, String firstName) {

        return teacherDAO.getByLastNameFirstName(lastName, firstName);
    }

    public List<TeacherDTO> findByName(String searchName, int start, int limit) {
        return teacherDAO.findByName(searchName,start,limit);
    }

    public Teacher getTeacherById(Integer id) {
        return teacherDAO.get(id);
    }

    public void updateTeacher(Teacher teacher) {
        teacherDAO.update(teacher);
    }

    public Teacher findByUserName(String userName) {
      return   teacherDAO.findByUserName(userName);

    }


    public void deleteTeacherTransactional(Teacher teacher, User user) {
        teacherDAO.deleteTeacherTransactional(teacher,user);
    }

    public List<Teacher> getAllTeacherFromAClass(SchoolClass classMaster) {
        return teacherDAO.getAllTeacherFromAClass(classMaster);  //To change body of implemented methods use File | Settings | File Templates.
    }

    public ITeacherDAO getTeacherDAO() {
        return teacherDAO;
    }

    public void setTeacherDAO(ITeacherDAO teacherDAO) {
        this.teacherDAO = teacherDAO;
    }
}
